/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Ventana_Registro.java
 *
 * Created on 26-abr-2013, 9:44:32
 */
package registros_personas;

import javax.swing.table.DefaultTableModel;

/**
 *
 * @author franck
 */
public class Ventana_Registro extends javax.swing.JFrame {

    /** Creates new form Ventana_Registro */
    public Ventana_Registro() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        txtApellidos = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtDireccion = new javax.swing.JTextField();
        txtTelefono = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(500, 400));
        getContentPane().setLayout(null);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nro", "Nombres", "Apellidos", "Direccion", "Telefono"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(20, 270, 760, 150);

        jLabel1.setText("Nombres");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(50, 40, 50, 14);
        getContentPane().add(txtNombre);
        txtNombre.setBounds(110, 30, 170, 20);
        getContentPane().add(txtApellidos);
        txtApellidos.setBounds(110, 60, 170, 20);

        jLabel3.setText("Apellidos");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(50, 60, 50, 14);

        jLabel4.setText("direccion");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(50, 90, 50, 14);

        jLabel5.setText("Telefono");
        getContentPane().add(jLabel5);
        jLabel5.setBounds(50, 120, 50, 14);
        getContentPane().add(txtDireccion);
        txtDireccion.setBounds(110, 90, 170, 20);

        txtTelefono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtTelefonoActionPerformed(evt);
            }
        });
        getContentPane().add(txtTelefono);
        txtTelefono.setBounds(110, 120, 170, 20);

        jButton1.setText("Agregar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1);
        jButton1.setBounds(340, 40, 71, 23);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txtTelefonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTelefonoActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_txtTelefonoActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        Object[] fila=new Object[5];
        int nro=jTable1.getRowCount();
        fila[0]=nro+1;
        fila[1]=txtNombre.getText();
        fila[2]=txtApellidos.getText();
        fila[3]=txtDireccion.getText();
        fila[4]=txtTelefono.getText();
        
        DefaultTableModel temp = (DefaultTableModel) jTable1.getModel();
        temp.addRow(fila);
        
        txtApellidos.setText("");
        txtDireccion.setText("");
        txtNombre.setText("");
        txtTelefono.setText("");
        
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Ventana_Registro().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField txtApellidos;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtTelefono;
    // End of variables declaration//GEN-END:variables
}
